<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include/src :: form_base_js_and_css"/>
</head>
<body style="background-color: #f2f2f2; height: 100%;">

	<div id="id_panel">
	</div>
	<script th:inline="javascript">

	// 表单初始化
	var formObj = null;
	//使用layui的sku模块
	layui.config({
	    //自定义layui组件的目录,设定扩展的layui模块的所在目录，一般用于外部模块扩展
	    base: '/static/js/layui_extends/',
		version: true
	}).use(['form', 'jquery', 'laydate', 'YsForm', 'YsModal'], function(){
		var $ = layui.jquery,
		form = layui.form,
				laydate = layui.laydate,
				YsForm = layui.YsForm,
				YsModal = layui.YsModal
		/* 
		* 表单初始化
		* 参数1：表单配置参数
		* 参数2：子表配置参数
		*/
		formObj = YsForm.init(
		{
			id:'id_panel', // 页面容器ID
			dto: $.parseJSON(JSON.stringify([[${dto}]]))
		}
		);

		/*
		 * 监听表格中各个数字型输入框
		*/
		var domForm1 = $('#' + formObj.c.id_form);
		domForm1.find('input[type="number"]').on('change',function (e) {
			calFormItem();
		});
		domForm1.find('input[name="status"]').on('change',function (e) {
			var statusVal = formObj.getValueByName("status");
			var userStateTxtVal = formObj.getValueByName("userStateTxt");
			if(statusVal==0){//停用
				if(userStateTxtVal!=undefined && userStateTxtVal!=null && userStateTxtVal!='' && userStateTxtVal!='离职'){
					var layerIndex = layer.confirm('该员工未离职是否确定停用？', {
						btn: ['确定', '取消'] //按钮
					}, function(){
						//确定
						layer.close(layerIndex);
					}, function(){
						formObj.setValueByName("status",1);
						var domParent = $(domForm1.find('input[name="status"]')).parent();
						var domDiv = domParent.find('div');
						var domEm = domParent.find('em');
						domDiv.prop('class', 'llayui-unselect layui-form-switch layui-form-onswitch');
						domEm.text("是")
						return;
					});
				}
			}
		});


		formObj.matchValuesAfterModalSelectRadio=function (colCode, rowSelected, extraData) { // 单选框选中数据后，匹配表单数值
			var t = formObj;
			var domForm = $('#' + t.c.id_form);
			for(var i = 0; i < t.c.dto.rows.length; i++){
				var col = t.c.dto.rows[i];
				if (col.code == colCode) {
					// 给选择框设置的字段赋值
					domForm.find('input[name="' + colCode + '"]').val(rowSelected[col.modalValueCode]);
				} else if(col.modalRelativeCode == colCode) {
					domForm.find('input[name="' + col.code + '"]').val(rowSelected[col.modalValueCode]);
				}
			}
			calFormItem();
		};
		if([[${onProcess}]]=='1'){
			//隐藏头部按钮
			$('#' + formObj.c.id_header).hide();
		}




		if([[${onProcess}]]=='0'){
			domForm1.find('input[name="dingDingId"]').on('click',function (e) {
				getDingDingUserIdByPhone();
			});
			/*
			var dingDingId = domForm1.find('input[name="dingDingId"]').val(); // 员工钉钉id
			//钉钉Id
			var addHtml = ``
					+ `<div class="layui-inline layui-col-xs4 margin_r_0">`
					+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10" title="用于从钉钉获取考勤数据">钉钉Id：</label>`
					+ `<div class="layui-input-block margin_l_150 min_height_38" style="padding-bottom: 120px;">`
					+ `<input type="text" class="layui-input" id="dingDingIdInput" onclick="getDingDingUserIdByPhone()" value="` + (dingDingId ? dingDingId : '') + `" readonly="readonly">`
					//+ `<button type="button" class="layui-btn layui-btn-primary" onclick="getDingDingUserIdByPhone(`+userId+`,`+telephone+`)">`+([[${onProcess}]]=="1"?`点击查看附件`:`点击上传附件`)+`<span id="fileCount">(`+fileCount+`个附件)</span></button>`
					+ `</div>`
					+ `</div>`;
			$('#' + formObj.c.id_form).find('.layui-form-item').append(addHtml);
			 */
		}




	});

	</script>
	<script type="text/javascript" src="/static/js/base/tbUserJobLevelManage/form-listen.js?v=2024060401"></script>

</body>
</html>
